<!DOCTYPE html>
<html>
	{include file="public1/_header" /}
	<style>
		.layui-table, .layui-table-view {
			margin: 10px 10px!important;
		}
	</style>
	<body style="background: #fff;">
		<div class="layui-row">
			<div class="layui-col-md12 layui-col-space15">
				<div class="layui-card">
					<table class="layui-table">
						<colgroup>
							<col width="12.5%">
							<col width="12.5%">
							<col width="12.5%">
							<col width="12.5%">
							<col width="12.5%">
							<col width="12.5%">
							<col width="12.5%">
							<col width="12.5%">
						</colgroup>
						<thead>
						<tr align="center">
							<th align="center">课节\星期一</th>
							<th align="center">星期一</th>
							<th align="center">星期二</th>
							<th align="center">星期三</th>
							<th align="center">星期四</th>
							<th align="center">星期五</th>
							<th align="center">星期六</th>
							<th align="center">星期日</th>
						</tr>
						</thead>
						<tbody>
						{foreach $result as $key=>$value }
						<tr>

							<td align="center">
								<span class="input-margin">
                                    <span>第{$value['number']}节</span><br>
									<span>{$value['start_time']}</span><br>
									<span>{$value['end_time']}</span>
                                </span>
							</td>

							{foreach $value['data'] as $k=>$v }
							<td align="center">
								<span class="input-margin">
                                    {$v['subject_name']|default=''}<br>
									{$v['teacher_name']|default='暂无设置'}
                                </span>
							</td>
							{/foreach}
						</tr>
						{/foreach}
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			var url = "__STATIC__/admin/";
			var getUrlParam = function(name) {
				var url = location.search;
				url = url.substring(url.indexOf("?"));
				if (url.indexOf("?") != -1) {
					var str = url.substr(1);
					strs = str.split("&");
					for (var i = 0; i < strs.length; i++) {
						if (name == strs[i].split("=")[0]) {
							return unescape(strs[i].split("=")[1]);
						}
					}
				}
				return "";
			}
			var nodeId = getUrlParam("nodeId");
			layui.extend({
				notice: 'notice/notice'
			}).use(['util', 'laydate', 'table', 'form', 'notice'], function() {
				var table = layui.table;
				var form = layui.form;
				var util = layui.util;
				var notice = layui.notice;
				var tableIns = table.render({
					id: 'testReload',
					elem: '#test',
					url: "{:url('timetable')}",
					method: "POST",
					where: {
						class_id: nodeId
					},
					cols: [
						[{
							type: 'checkbox',
							fixed: 'left',
							width: 80
						}, {
							field: 'sort',
							title: "排序",
							width: 80,
							edit: true,
							sort: true
						}, {
							field: 'honorary_name',
							title: "名称"
						}, {
							field: 'start_time',
							title: "开始日期",
							templet: function(d) {
								var logoSrc = util.toDateString(d.start_time * 1000, "yyyy-MM-dd HH:mm:ss");
								return logoSrc;
							},
							sort: true
						}, {
							field: 'end_time',
							title: "结束日期",
							templet: function(d) {
								var logoSrc = util.toDateString(d.end_time * 1000, "yyyy-MM-dd HH:mm:ss");
								return logoSrc;
							},
							sort: true
						}, {
							field: 'created_at',
							title: "发布日期",
							sort: true
						}, {
							field: 'image',
							title: "证书",
							width: 80,
							templet: function(d) {
								if (d.image) {
									var logoSrc = "<img src='" + d.image +
										"'  width='35' height='26' style='border:1px solid #ccc;box-sizing:border-box' />";
								} else {
									var logoSrc = "<img alt='暂无图片' src='" + url + "images/imageno.png' width='40' />";
								}
								return logoSrc;
							},
							event: "nameClick"
						}, {
							field: 'istop',
							title: "置顶",
							width: 80,
							templet: function(d) {
								if (d.istop == 1) {
									var check = "<input type='checkbox' value='" + d.id +
										"' lay-filter='istop' lay-skin='switch' lay-text='是|否' checked>";
								} else if (d.istop == 0) {
									var check = "<input type='checkbox' value='" + d.id +
										"' lay-filter='istop' lay-skin='switch' lay-text='是|否'>";
								}

								return check;
							}
						}, {
							field: 'show',
							title: "显示",
							width: 80,
							templet: function(d) {
								if (d.show == 1) {
									var check = "<input type='checkbox' value='" + d.id +
										"' lay-filter='show' lay-skin='switch' lay-text='是|否' checked>";
								} else if (d.show == 0) {
									var check = "<input type='checkbox' value='" + d.id +
										"' lay-filter='show' lay-skin='switch' lay-text='是|否'>";
								}

								return check;
							}
						}, {
							fixed: 'right',
							title: "{:lang('action')}",
							toolbar: '#barDemo',
							width: 180
						}]
					],
					page: false
				});
			});
		</script>
	</body>
</html>
